package com.atguigu.lease.common.minio;


import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/*
@Configuration
@EnableConfigurationProperties(MinioProperties.class)
public class MinioConfiguration {
    @Autowired
    private MinioProperties minioProperties;
    @Bean
    public MinioClient minioClient() {
        MinioClient minioClient = MinioClient.builder()
                .endpoint(minioProperties.getEndpoint())
                .credentials(minioProperties.getAccessKey(), minioProperties.getSecretKey())
                .build();
        return minioClient;
    }
}*/
@Configuration
//在编译后，这个注解会将我们当前类加入到META-INF中，加入到了配置类清单中
@EnableConfigurationProperties(MinioProperties.class)
//这个类用于创建对象minioclient，并且将minioclient加入到ioc容器中
public class MinioConfiguration {
    //将minioProperties中的信息注入进来
    @Autowired
    private MinioProperties properties;

    //@bean-->注解，将下方创建的对象..加入到了ioc容器
    //并将这个ioc容器的对象提供给admin/app使用
    @Bean
    public MinioClient minioClient(){
        //创建了client对象----》
        MinioClient minioClient = MinioClient.builder()
                .endpoint(properties.getEndpoint())
                .credentials(properties.getAccessKey(), properties.getSecretKey())
                .build();
        return minioClient;
    }

}
